﻿using FinancePortal.Business.Infraestructure;
using FinancePortal.Business.Repository;
using FinancePortal.Domain.Model;
using System.Collections.Generic;
using System;
using System.Linq;

namespace FinancePortal.Business.Implementation
{
    public class VacationScheduleRepository : RepositoryBase<VacationSchedule>, IVacationScheduleRepository
    {
        public VacationScheduleRepository(IUnitOfWork uow)
            : base(uow)
        { }

        public IList<VacationSchedule> GetByResource(int resourceId, DateTime fromDate)//, DateTime toDate)
        {
            var list = (from a in GetAll()
                        where (a.Resource.Id == resourceId)
                            //|| a.Participants.Any(r => r.Id == resourceId))
                            && a.FromDate >= fromDate
                            //&& a.ToDate <= toDate
                        select a).ToList();

            return list;
        }

        public IList<VacationSchedule> GetByArea(int areaId)
        {
            var list = (from a in GetAll()
                        where a.Resource.AreaId == areaId
                        select a).ToList();

            return list;
        }
    }
}
